<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>K吧</title>
<link rel="stylesheet" type="text/css" href="<s:property value="staticsRoot"/>/css/front-style.css"/>
<link href="http://www.7k7kjs.cn/qike_public/qike-sns.min.css" rel="stylesheet" />
<script src="http://www.7k7kjs.cn/js/lib/jquery/1.7.2/jquery-min.js"></script>
<script src="http://www.7k7kjs.cn/qike_public/qike-sns.min.js"></script>
<script type="text/javascript" src="<s:property value="staticsRoot"/>/js/jquery-1.8.3.min.js"></script>
<script>document.domain="7k7k.com";</script>
<link rel="stylesheet" type="text/css" href="<s:property value="staticsRoot"/>/css/common.css" media="screen" />
<script type="text/javascript" charset="utf-8" src="<s:property value="staticsRoot"/>/js/kindeditor.js"></script>
<script type="text/javascript" charset="utf-8" src="<s:property value="staticsRoot"/>/js/lang/zh_CN.js"></script>
<script type="text/javascript">
var editor;
$(document).ready(function(){
	$(".mess .i_text").click(function(){
		$(".mess li span").removeClass("dis_none");		
	});
});
KindEditor.ready(function(K) {
	editor = K.create('textarea[id="content"]', {
		allowFileManager : false,
		uploadJson : './upload.html',
		filePostName : 'filedata',
		urlType : 'domain',
		items : [
		'undo', 'redo', 'preview', '|', 
		'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'quickformat', '|',		 
		'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'removeformat', '|', 
		'image', 'insertfile', 'table', 'hr', 'emoticons', 'anchor', 'link', 'unlink','|', 
		'about' 
		]
	});
});
</script>
<style type="text/css">

<s:if test="barDO.image	!=null&&barDO.image!='noImage'"> 
body{
	
    background: url(<s:property value="barDO.image"/>);
    background-repeat: no-repeat;
    background-position:center top;
}
.no-bg {
	background: #fff;
	width: 1210px;
	margin: 0px auto;
}
</s:if>
</style>
</head>

<body> 
<s:if test="barDO.image	!=null&&barDO.image!='noImage'"> 
 <div class="no-bg">
 </s:if>
<s:include value="include/header.jsp"/>
<div class="adress">
	<a href='<s:property value="domainRoot"/>/index.html'>k吧 </a>&gt;
    <a href='<s:property value="domainRoot"/>/listThread.html?barId=<s:property value="barId"/>'><s:property value="barDO.name"/></a>&gt;
    <span>主题列表</span>
</div>
<!--top-->
<s:action name="top" executeResult="true"/>
<div class="mian">
	<div class="left fl">
    	<ul class="tab_ul">
        	<li <s:if test="categoryId == null || categoryId == 0"> class="on" </s:if>><a href='<s:property value="domainRoot"/>/listThread.html?barId=<s:property value="barId"/>'>浏览所有</a></li>
        	<s:if test="barId != noticeBarId">
            <li <s:if test="categoryId == -2"> class="on" </s:if>><a href='<s:property value="domainRoot"/>/listThread.html?barId=<s:property value="barId"/>&categoryId=-2'>精华</a></li>
            </s:if>
            <s:iterator value="threadCategoryList" status="status" id="threadCategory">            
            <li <s:if test="categoryId == #threadCategory.id"> class="on" </s:if>><a href='<s:property value="domainRoot"/>/listThread.html?barId=<s:property value="barId"/>&categoryId=<s:property value="#threadCategory.id"/>'><s:property value="#threadCategory.name"/></a></li>
            </s:iterator>
			<s:if test="barDO.status == 0">
            <span><a href="#publish" class="fbxt">发表新帖</a></span>
            </s:if>
        </ul>
		<table width="100%" cellpadding="0" cellspacing="0" class="sj">
        	<tr>
            	<th align="center">点击</th>
                <th align="center">回复</th>
                <th align="left">主题</th>
                <th align="left">作者</th>
                <th align="left">最后更新</th>
                <th align="left">更新时间</th>
            </tr>
            <s:iterator value="threadList" status="status" id="thread">
            <tr>
            	<td align="center"><s:if test="#thread.viewCount > 100"><strong class="red"><s:property value="#thread.viewCount"/></strong></s:if><s:else><s:property value="#thread.viewCount"/></s:else></td>
                <td align="center"><s:if test="#thread.replyCount > 100"><strong class="red"><s:property value="#thread.replyCount"/></strong></s:if><s:else><s:property value="#thread.replyCount"/></s:else></td>
                <td align="left"><s:if test="#thread.sticky == 1"><strong class="red_top">[置顶]</strong></s:if><a href="<s:property value="domainRoot"/>/listThreadReply.html?barId=<s:property value="barId"/>&threadId=<s:property value="#thread.id"/>" target="_blank"> <s:property value="shortString(#thread.title,18)"/></a><s:if test="#thread.viewCount > 100"><img src="<s:property value="staticsRoot"/>/images/post_hot.png" /></s:if><s:if test="#thread.digest == 1"><img src="<s:property value="staticsRoot"/>/images/post_digest.png" /></s:if><s:if test="#thread.status == 1"><img src="<s:property value="staticsRoot"/>/images/post_lock.png" /></s:if></td>
				<td align="left"><a href='http://my.7k7k.com/space/<s:property value="#thread.createId"/>'target="_blank"><s:property value="shortString(userMap.get(#thread.createId).nick, 6)" /></a></td>
                <td align="left"><a href='http://my.7k7k.com/space/<s:property value="#thread.lastReplyId"/>'target="_blank"><s:property value="shortString(userMap.get(#thread.lastReplyId).nick, 6)"/></a></td>
                <td align="left"><s:property value="#thread.modifiedTime"/></td>
            </tr>
            </s:iterator>
		</table>
       <s:include value="include/pageNav.jsp"/>       
       <s:set name="user" value="kbaUser"/>
       <s:if test="banIp || (#user != null && (#user.status==1 || #user.isForbid()))">
		<span class="red">你已被禁言，不允许发贴!</span>
       </s:if>
       <s:else><!-- else not banIp -->
	       <s:if test="barDO.status == 0">
		       <form id="form" name="publishForm" action="publishThread.html" method="post" onsubmit="return doPublish();" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">
		       <input type="hidden" name="barId" value="<s:property value="barId"/>"/>
		       <input type="hidden" name="categoryId" value="<s:property value="categoryId"/>"/>
		       <input type="hidden" name="threadDO.barId" value="<s:property value="barId"/>"/>
		       <ul class="mess" id="publish">
		        	<li>
		            	<select name="threadDO.categoryId">
		                	<option value="0">选择类型</option>
		                	<s:iterator value="threadCategoryList" status="status" id="threadCategory">
		                	<option value="<s:property value="#threadCategory.id"/>"><s:property value="#threadCategory.name"/></option>
		            		</s:iterator>
		                </select>
		                <input type="text" class="i_text" name="threadDO.title" id="title"/>&nbsp;<span id="titleErr" class="red"></span>
		            </li>
		            <li class="special">
		              <textarea id="content" name="threadDO.content" maxlength="65534" style="width:800px;height:400px;visibility:hidden;" escape="false"></textarea>
		              <br/>
		              <span id="contentErr" class="red"></span>
		          </li>
		            <li>验证码：<input type="text" id="securityCode" name="securityCode" class="i_text" style="width:100px;" value="点击输入验证码" onblur="if(this.value=='') {this.value='点击输入验证码';this.style.color='#999999';}" onfocus="if(this.value=='点击输入验证码') {this.value='';}this.style.color='#000';" /><span class="dis_none"><img src="securityCode.html" id="verify"/>看不清？<a href="###" onclick="changeSecurityCode();">换一张</a></span><br/><span id="securityCodeErr" class="red"></span></li>
		            <li><input type="submit" value=" " class="sub_btn" /></li>
		        </ul>
		        </form>
	        </s:if>
	        <s:else><span class="red">本吧已经被锁定，不允许发贴！</span>！</s:else><!-- else barDo.status == 1 -->
       </s:else>
    </div>
    <!--right-->
    <s:action name="right" executeResult="true"/>
    <div class="clearB"></div>    
	<form action="listThread.html" method="post" id="searchForm">
		<input type="hidden" id ="toPage" name="page" value="<s:property value="queryDO.toPage"/>"/>
		<input type="hidden" id ="barId" name="barId" value="<s:property value="barId"/>"/>
		<input type="hidden" id ="categoryId" name="categoryId" value="<s:property value="categoryId"/>"/>
	</form>
</div>
<s:include value="include/foot.jsp"/>

<s:if test="barDO.image	!=null&&barDO.image!='noImage'"> 
 </div>
 </s:if>
</body>
<script language="javascript">
    function doSearch(pageNumber, totalItem){
		if(pageNumber <= 0){
			pageNumber = 1;
		}	
		$("#toPage").val(pageNumber); 
		$("#searchForm").submit(); 
	}
  
	//点击图片更换验证码
	function changeSecurityCode(){
		$("#verify").attr("src","securityCode.html?timestamp="+new Date().getTime());
	}

	var count = 0;
	//验证发贴
	function doPublish(){	
		if(count != 0){
			alert("请求提交中.请稍候.");
			return false;
		}
		$("#titleErr").html("");
		$("#contentErr").html("");
		$("#securityCodeErr").html("");
		//验证标题
		var title = $("#title").val();
		if(title == "" ){
			$("#titleErr").html("标题不能为空");
			return false;
		}
		if(title.length > 60){
			$("#titleErr").html("标题不能超过60个字");
			return false;	
		}
		<s:if test="#user != null && !#user.getBarRoleByBarId(barId)">
		//判断汉字
		var hanzi = title.match(/[^\x00-\xff]/ig);
		var hanziLength = 0;
		if(hanzi != null){
			hanziLength = hanzi.length;
		}   
		if(hanziLength < 16){
			$("#titleErr").html("标题不能少于16个汉字");
			return false;	
		}	
		</s:if>	
		
		//验证内容
		if(editor.html() == ""){
			$("#contentErr").html("帖子内容不能为空");
			return false;
		}
		if(editor.html().length > 65534){
			$("#contentErr").html("帖子内容不能超过65534个字");
			return false;
		}
		<s:if test="#user != null && !#user.getBarRoleByBarId(barId)">
		hanzi = editor.html().match(/[^\x00-\xff]/ig);
		hanziLength = 0;
		if(hanzi != null){
			hanziLength = hanzi.length;
		}    
		if(hanziLength < 20){
			$("#contentErr").html("内容不能少于20个汉字");
			return false;	
		}	
		if(editor.text().length <= 0){
			$("#contentErr").html("请不要发布水贴");
			return false;	
		}
		</s:if>
		
		//验证验证码
		var securityCode = $("#securityCode").val();
		if(securityCode == "" || securityCode == "点击输入验证码"){
			$("#securityCodeErr").html("验证码不能为空");
			return false;
		}
		
		//（同步)ajax请求
		var flag = false;
	 	$.ajax({
	    	type: "get",
	    	url: "ajaxVerifySecurityCode.html",
	    	data: {"securityCode":securityCode},
			async:false,
			contentType: "application/json; charset=utf-8",
			dataType: "json",
			cache: false,			
	    	beforeSend:function(){},
	   		success: function(result)	{
						if ($.trim(result.isSuccess)=="1"){		
							flag = true;
						}else{				
							$("#securityCodeErr").html("验证码错误");
						}
					 },
	    	complete:function(){}
		});
		
		if(flag){
			count ++;
			return true;
		}else{
			return false;
		}
	}
</script>
</html>
